#include<iostream>
#include"Matrix.h"

using namespace std;

int main(){
    //Test 1
    cout<<"Test1: Create matrices A and B."<<endl;
    cout<<"Please <Enter> the size of A like (row<blankspace>column): "<<endl;
    int ar,ac;
    cin>> ar >> ac; cout<<ar<<' '<<ac<<endl;
    matrix<int> A(ar,ac);
    cout<<"Please complete matrix A by the dictionary order of <row,column>: "<<endl;
    for(int i=1;i<=ar;i++) for(int j=1;j<=ac;j++) cin>> A(i,j);
    //cout<<"Please confirm matrix A: (If some mistakes occur, use <Ctrl+C> to retry)"<<endl;
    A.mprint();

    cout<<"Please <Enter> the size of B: "<<endl;
    int br,bc;
    cin>> br >> bc; cout<<br<<' '<<bc<<endl;
    matrix<int> B(br,bc);
    cout<<"Please complete matrix B: "<<endl;
    for(int i=1;i<=br;i++) for(int j=1;j<=bc;j++) cin>> B(i,j);
    //cout<<"Please confirm matrix B: (If some mistakes occur, use <Ctrl+C> to retry)"<<endl;
    B.mprint();

    cout<<endl;
    //Test 2
    cout<<"Test2: Is the matrix square?"<<endl;
    cout<<"Is A a square matrix?"<<endl;
    cout<<(A.is_square()?"Yes, A is.":"No A is not.")<<endl;
    cout<<"Is B a square matrix?"<<endl;
    cout<<(B.is_square()?"Yes, B is.":"No B is not.")<<endl;

    cout<<endl;
    //Test 3
    cout<<"Test3: Mutiplication between two matrices."<<endl;
    if((A*B).is_matrix()){
        cout<<"Here comes A*B:"<<endl;
        (A*B).mprint();}
    else cout<<"A*B is not a legal mutiplication."<<endl;
    if((B*A).is_matrix()){
        cout<<"Here comes B*A:"<<endl;
        (B*A).mprint();}
    else cout<<"B*A is not a legal mutiplication."<<endl;

    cout<<endl;
    //Test 4
    cout<<"Test4: Creating some row vectors and column vectors."<<endl;
    cout<<"Please enter 4 numbers as size of vectors x,y,z,w here: "<<endl;
    int xs,ys,zs,ws; cin>>xs>>ys>>zs>>ws; cout<<xs<<' '<<ys<<' '<<zs<<' '<<ws<<' '<<endl;
    rowvector<int> x(xs); rowvector<int> y(ys);
    colvector<int> z(zs); colvector<int> w(ws);
    cout<<"Please complete the row vector x here: "<<endl;
    for(int i=1;i<=xs;i++) cin>> x(i);
    //cout<<"Please confirm: "<<endl;
    x.printrow();
    cout<<"Please complete the row vector y here: "<<endl;
    for(int i=1;i<=ys;i++) cin>> y(i);
    //cout<<"Please confirm: "<<endl;
    y.printrow();
    cout<<"Please complete the column vector z here: "<<endl;
    for(int i=1;i<=zs;i++) cin>> z(i);
    //cout<<"Please confirm: "<<endl;
    z.printcol();
    cout<<"Please complete the column vector w here: "<<endl;
    for(int i=1;i<=ws;i++) cin>> w(i);
    //cout<<"Please confirm: "<<endl;
    w.printcol();

    //Test 5
    cout<<"Test5: Mutiplication between two vectors."<<endl;
    if(x.get_length()!=y.get_length()){
        x*y;
    }else cout<< "Here comes x*y: " << x*y << endl;
    if(z.get_height()!=w.get_height()){
        z*w;
    }else cout<< "Here comes z*w: " << z*w << endl;
    if(x.get_length()!=z.get_height()){
        x*z;
    }else cout<< "Here comes x*z: " << x*z << endl;
    if(x.get_length()!=w.get_height()){
        x*w;
    }else cout<< "Here comes x*w: " << x*w << endl;
    if(y.get_length()!=z.get_height()){
        y*z;
    }else cout<< "Here comes y*z: " << y*z << endl;
    if(y.get_length()!=w.get_height()){
        y*w;
    }else cout<< "Here comes y*w: " << y*w << endl;

    if(x.get_length()!=z.get_height()){
        z*x;
    }else cout<< "Here comes z*x: " << endl;
    (z*x).mprint();
    if(x.get_length()!=w.get_height()){
        w*x;
    }else cout<< "Here comes w*x: " << endl;
    (w*x).mprint();
    if(y.get_length()!=z.get_height()){
        z*y;
    }else cout<< "Here comes z*y: " << endl;
    (z*y).mprint();
    if(y.get_length()!=w.get_height()){
        w*y;
    }else cout<< "Here comes w*y: " << endl;
    (w*y).mprint();
}
